package com.goodving.guli.bt.profile.scale;

/**
 * Created by john on 2015/12/13.
 */

import android.annotation.SuppressLint;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class FrkWeightProfile
{
    public static long byte2int(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    {
        long l = 0L;
        if (paramInt1 > paramInt2)
            paramInt1 = paramInt2;
        if (paramInt2 >= paramArrayOfByte.length)
            paramInt2 = -1 + paramArrayOfByte.length;
        int i = 0;
        while (true)
        {
            if (paramInt1 > paramInt2)
                return l;
            l += ((0xFF & paramArrayOfByte[paramInt1]) << i * 8);
            i++;
            paramInt1++;
        }
    }

    private static String calculateBmi(double paramDouble, float paramFloat)
    {
        Object[] arrayOfObject = new Object[1];
        arrayOfObject[0] = Double.valueOf(paramDouble / (0.01D * (0.01D * paramFloat * paramFloat)));
        String str = String.format("%.1f", arrayOfObject);
        if (str.contains(","))
            str = str.replace(",", ".");
        return str;
    }

    public static int getDeviceType(byte[] paramArrayOfByte)
    {
        int i = -1;
        if (((0xFF & paramArrayOfByte[4]) == 176) && ((0xFF & paramArrayOfByte[6]) == 165))
            i = 0;
        do
        {

            if (((0xFF & paramArrayOfByte[4]) == 177) || ((0xFF & paramArrayOfByte[7]) == 177))
                return 1;
            if (((0xFF & paramArrayOfByte[4]) == 176) && ((0xFF & paramArrayOfByte[6]) == 90))
                return 2;
            if (((0xFF & paramArrayOfByte[2]) == 2) && ((0xFF & paramArrayOfByte[3]) == 226))
                return 3;
        }
        while (((0xFF & paramArrayOfByte[9]) != 11) || ((0xFF & paramArrayOfByte[10]) != 222));
        return 4;
    }

    @SuppressLint({"SimpleDateFormat"})
    public static Map<String, Object> getMessage(byte[] paramArrayOfByte, float paramFloat, int paramInt)
    {
        Object localObject;
//        if (paramArrayOfByte == null)
        localObject = null;
        do
        {
            int i = 0;
            do
            {
                //return (Map) localObject;
                localObject = new HashMap();
                switch (paramInt)
                {
                    case 4:
                    default:
                        return (Map)localObject;
                    case 0:
                        double d2 = 0.0D;
                        for (int i8 = 11; ; i8++)
                        {
                            if (i8 >= 15)
                            {
                                Object[] arrayOfObject15 = new Object[1];
                                arrayOfObject15[0] = Double.valueOf(0.1D * d2);
                                String str22 = String.format("%.1f", arrayOfObject15);
                                if (str22.contains(","))
                                    str22 = str22.replace(",", ".");
                                ((Map)localObject).put("weight", str22);
                                String str23 = calculateBmi(0.1D * d2, paramFloat);
                                ((Map)localObject).put("BMI", str23);
                                String str24 = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
                                ((Map)localObject).put("date", str24);
                                return (Map)localObject;
                            }
                            d2 += ((0xFF & paramArrayOfByte[i8]) >> 4) * (int)Math.pow(16.0D, -1 + (15 - i8));
                        }
                    case 1:
                        int m = (int)byte2int(paramArrayOfByte, 0, 0);
                        if (m == 1)
                        {
                            int i7 = (int)byte2int(paramArrayOfByte, 1, 2);
                            Object[] arrayOfObject14 = new Object[1];
                            arrayOfObject14[0] = Double.valueOf(0.1D * i7);
                            String str20 = String.format("%.1f", arrayOfObject14);
                            if (str20.contains(","))
                                str20 = str20.replace(",", ".");
                            ((Map)localObject).put("weight", str20);
                            String str21 = calculateBmi(0.1D * i7, paramFloat);
                            ((Map)localObject).put("BMI", str21);
                            return (Map)localObject;
                        }
                        if ((m == 2) && ((0x8 & paramArrayOfByte[3]) == 8))
                        {
                            int i6 = (int)byte2int(paramArrayOfByte, 1, 2);
                            Object[] arrayOfObject13 = new Object[1];
                            arrayOfObject13[0] = Double.valueOf(0.1D * i6);
                            String str18 = String.format("%.1f", arrayOfObject13);
                            if (str18.contains(","))
                                str18 = str18.replace(",", ".");
                            ((Map)localObject).put("weight", str18);
                            String str19 = calculateBmi(0.1D * i6, paramFloat);
                            ((Map)localObject).put("BMI", str19);
                            return (Map)localObject;
                        }
                        if (m == 2)
                        {
                            int n = (int)byte2int(paramArrayOfByte, 1, 2);
                            i = (int)byte2int(paramArrayOfByte, 3, 3);
                            int i1 = (int)byte2int(paramArrayOfByte, 4, 5);
                            int i2 = (int)byte2int(paramArrayOfByte, 6, 7);
                            int i3 = (int)byte2int(paramArrayOfByte, 8, 9);
                            int i4 = (int)byte2int(paramArrayOfByte, 10, 11);
                            int i5 = (int)byte2int(paramArrayOfByte, 12, 12);
                            Object[] arrayOfObject7 = new Object[1];
                            arrayOfObject7[0] = Double.valueOf(0.1D * n);
                            String str10 = String.format("%.1f", arrayOfObject7);
                            if (str10.contains(","))
                                str10 = str10.replace(",", ".");
                            ((Map)localObject).put("weight", str10);
                            String str11 = calculateBmi(0.1D * n, paramFloat);
                            ((Map)localObject).put("BMI", str11);
                            Object[] arrayOfObject8 = new Object[1];
                            arrayOfObject8[0] = Double.valueOf(0.1D * i1);
                            String str12 = String.format("%.1f", arrayOfObject8);
                            if (str12.contains(","))
                                str12 = str12.replace(",", ".");
                            ((Map)localObject).put("fat", str12);
                            Object[] arrayOfObject9 = new Object[1];
                            arrayOfObject9[0] = Double.valueOf(0.1D * i3);
                            String str13 = String.format("%.1f", arrayOfObject9);
                            if (str13.contains(","))
                                str13 = str13.replace(",", ".");
                            ((Map)localObject).put("muscle", str13);
                            Object[] arrayOfObject10 = new Object[1];
                            arrayOfObject10[0] = Double.valueOf(0.1D * i5);
                            String str14 = String.format("%.1f", arrayOfObject10);
                            if (str14.contains(","))
                                str14 = str14.replace(",", ".");
                            ((Map)localObject).put("bone", str14);
                            Object[] arrayOfObject11 = new Object[1];
                            arrayOfObject11[0] = Double.valueOf(0.1D * i2);
                            String str15 = String.format("%.1f", arrayOfObject11);
                            if (str15.contains(","))
                                str15 = str15.replace(",", ".");
                            ((Map)localObject).put("water", str15);
                            Object[] arrayOfObject12 = new Object[1];
                            arrayOfObject12[0] = Integer.valueOf(i4);
                            String str16 = String.format("%d", arrayOfObject12);
                            if (str16.contains(","))
                                str16 = str16.replace(",", ".");
                            ((Map)localObject).put("cal", str16);
                            String str17 = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
                            ((Map)localObject).put("date", str17);
                            return (Map)localObject;
                        }
                        ((Map)localObject).put("error", "鐢熺墿闃绘姉寮傚父");
                        return (Map)localObject;
                    case 2:
                        int j = 0;
                        for (int k = 11; ; k++)
                        {
                            if (k > 14)
                            {
                                double d1 = j * 1;
                                Object[] arrayOfObject6 = new Object[1];
                                arrayOfObject6[0] = Double.valueOf(d1);
                                String str8 = String.format("%.0f", arrayOfObject6);
                                if (str8.contains(","))
                                    str8 = str8.replace(",", ".");
                                ((Map)localObject).put("weight", str8);
                                String str9 = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
                                ((Map)localObject).put("date", str9);
                                return (Map)localObject;
                            }
                            j += ((0xFF & paramArrayOfByte[k]) >> 4) * (int)Math.pow(16.0D, -1 + (15 - k));
                        }
                    case 3:
                }
                if ((0xFF & paramArrayOfByte[9]) != 192)
                    break;
                i = toInt(paramArrayOfByte, 11, 11, true, 255L);
            }
            while (i > 300);
            Object[] arrayOfObject5 = new Object[1];
            arrayOfObject5[0] = Integer.valueOf(i);
            String str6 = String.format("%d", arrayOfObject5);
            if (str6.contains(","))
                str6 = str6.replace(",", ".");
            ((Map)localObject).put("SBP", str6);
            String str7 = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
            ((Map)localObject).put("date", str7);
//            return (Map)localObject;
            if ((0xFF & paramArrayOfByte[9]) == 193)
            {
                Object[] arrayOfObject2 = new Object[1];
                arrayOfObject2[0] = Integer.valueOf(0xFF & paramArrayOfByte[10]);
                String str2 = String.format("%d", arrayOfObject2);
                if (str2.contains(","))
                    str2 = str2.replace(",", ".");
                ((Map)localObject).put("SBP", str2);
                Object[] arrayOfObject3 = new Object[1];
                arrayOfObject3[0] = Integer.valueOf(0xFF & paramArrayOfByte[11]);
                String str3 = String.format("%d", arrayOfObject3);
                if (str3.contains(","))
                    str3 = str3.replace(",", ".");
                ((Map)localObject).put("DBP", str3);
                Object[] arrayOfObject4 = new Object[1];
                arrayOfObject4[0] = Integer.valueOf(0xFF & paramArrayOfByte[12]);
                String str4 = String.format("%d", arrayOfObject4);
                if (str4.contains(","))
                    str4 = str4.replace(",", ".");
                ((Map)localObject).put("HR", str4);
                String str5 = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
                ((Map)localObject).put("date", str5);
                return (Map)localObject;
            }
        }
        while ((0xFF & paramArrayOfByte[9]) != 194);
        Object[] arrayOfObject1 = new Object[1];
        arrayOfObject1[0] = Byte.valueOf(paramArrayOfByte[8]);
        String str1 = String.format("%02X", arrayOfObject1);
        if (str1.contains(","))
            str1 = str1.replace(",", ".");
        ((Map)localObject).put("error", str1);
        return (Map) localObject;
    }

    private static int toInt(byte[] paramArrayOfByte, int paramInt1, int paramInt2, boolean paramBoolean, long paramLong)
    {
        return 0;
//        int i = paramInt2 - paramInt1;
//        long l1 = 0L;
//        if (paramInt1 > paramInt2)
//            return (int)l1;
//        int j = (byte)(0xFF & paramArrayOfByte[paramInt1]);
//        int k = 0;
//        long l2;
//        LargeTest:
//        if (paramBoolean)
//        {
//            k = paramInt2 - paramInt1;
//            l2 = j << k * 8;
//            if (!paramBoolean)
//
//        }
//        for (int m = i - (paramInt2 - paramInt1); ; m = paramInt2 - paramInt1)
//        {
//            l1 += (l2 & paramLong >> m * 8);
//            paramInt1++;
//            break ;
//            k = i - (paramInt2 - paramInt1);
//            break LargeTest ;
//        }
//        return k;
    }
}

/* Location:           E:\study\android apk decompile\jd-gui-0.3.5.windows\classes-dex2jar.jar
 * Qualified Name:     com.gd123.healthmanager.ble.BLEMessage
 * JD-Core Version:    0.6.2
 */